package com.lym.product.service.impl;

import com.lym.product.bean.Product;
import com.lym.product.service.ProductService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

/**
 * 商品服务实现类
 */
@Service
public class ProductServiceImpl implements ProductService {

    /**
     * 根据商品id获取商品信息
     *
     * @param productId
     * @return
     */
    @Override
    public Product getProductById(Long productId) {
        Product product = new Product();
        product.setId(productId);
        product.setPrice(new BigDecimal(7999));
        product.setProductName("苹果 - " + productId);
        product.setNum(100);

        /**
         * 模拟超时
         */
//        try {
//            TimeUnit.SECONDS.sleep(100);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }

        return product;
    }

}
